package com.smarthospital.web.controller;

import com.github.pagehelper.PageInfo;
import com.smarthospital.common.Result.ResultDTO;
import com.smarthospital.entity.pojo.CooperDoctor;
import com.smarthospital.entity.pojo.CooperHospital;
import com.smarthospital.entity.pojo.CooperMajorRoom;
import com.smarthospital.service.HospitalRegisterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * create by sym  2020/8/16 16:00.
 */
@RestController
@Slf4j
@RequestMapping("/hosRegist")
@Api(tags = "预约挂号")
public class HospitalRegisterController {

    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    HospitalRegisterService hospitalRegisterService;

    @GetMapping("/hospitals")
    @ApiOperation(value = "医院列表")
    public ResultDTO hospitals(@RequestHeader("SH_TOKEN")String SH_TOKEN,@RequestParam("pageNum") String pageNum
            ,@RequestParam("pageSize") String pageSize) throws Exception {

        PageInfo<CooperHospital> list =  hospitalRegisterService.hospitals(pageNum,pageSize);
        return ResultDTO.sucess(list);
    }

    @GetMapping("/majors")
    @ApiOperation(value = "科室列表")
    public ResultDTO majors(@RequestHeader("SH_TOKEN")String SH_TOKEN,@RequestParam("hospitalId") String hospitalId,
            @RequestParam("pageNum") String pageNum,@RequestParam("pageSize") String pageSize) throws Exception {
        log.info("科室列表 param {}", hospitalId);
        PageInfo<CooperMajorRoom> list =  hospitalRegisterService.QueryMajorRooms(hospitalId,pageNum,pageSize);
        return ResultDTO.sucess(list);
    }

    @GetMapping("/doctors")
    @ApiOperation(value = "科医生列表")
    public ResultDTO doctors(@RequestHeader("SH_TOKEN")String SH_TOKEN,@RequestParam("majorId") String majorId,
                            @RequestParam("pageNum") String pageNum,@RequestParam("pageSize") String pageSize) throws Exception {
        log.info("科室列表 param {}", majorId);
        PageInfo<CooperDoctor> list =  hospitalRegisterService.QueryDoctors(majorId,pageNum,pageSize);
        return ResultDTO.sucess(list);
    }


}
